/*
* @Author: xfy
* @Date:   2017-08-29 14:08:46
* @Last Modified by:   xfy
* @Last Modified time: 2017-08-29 15:28:38
*/
'use strict';
require('./index.css');
require('page/common/nav/index.js');
require('page/common/header/index.js');
var navSide         = require('page/common/nav-side/index.js');
var _supper         = require('util/supper.js');
var _user           = require('service/user-service.js');
var templateIndex   = require('./index.string');

//page逻辑部分
var page = {
    init : function(){
        this.onLoad();
    },
    onLoad : function(){
        //初始化左侧菜单
        navSide.init({
            name : 'user-center'
        });
        //加载用户信息
        this.loadUserInfo();
    },
    //加载用户信息
    loadUserInfo : function(){
        var userHtml = '';
        _user.getUserInfo(function(res){
            res.sex = res.sex ? '男' : '女'
            userHtml = _supper.renderHtml(templateIndex, res);
            $('.panel-body').html(userHtml);
        }, function(errMsg){
            $('.panel .panel-body .loading').hide();
            $('.panel .panel-body .error-tip').show();
        });
    }
};
$(function(){
    page.init();
});